#include<bits/stdc++.h>
using namespace std;
/*int f(int n)
{
    for (int i=2; i*i<=n; i++)
    {
        if ( n%i == 0 )
            return 0;
    }
    return 1;
}

int main()
{
    int N;
    int t=0;
    scanf("%d",&N);
    if(N==3)
    t=1;
    for(int i=2; i+2<=N; i++)
    {
        if(f(i)==1 and f(i+2)==1 or f(i)==1 and f(i+1)==1)
        {
t++;
        }
}
    printf("%d",t);

    return 0;
}*/
int main() {

	int N, cnt = 0;
	int arr[78498];
	cin>>N;
	arr[0] = 2;

	for (int i = 3; i <= N; i += 2) {
		int Prime = 1;

		for (int j = 3; j <= sqrt(i); j += 2) {
			if (i % j == 0) {
				Prime = 0;
				break;
			}
		}

		if (Prime) {

			arr[++cnt] = i;
		}
	}
	
for (int i = 1; i <=cnt; i++) cout<<arr[i]<<" ";cout<<endl;
	 
	int cnt2 = 0;
	for (int i = 1; i <=cnt; i++) {
		if (arr[i] - arr[i - 1] <= 2) {
			cnt2++;
		}
		
	}cout<<cnt2;
}
